<?php

namespace App\Http\Models;

use Illuminate\Database\Eloquent\Model;

/**
 * App\Http\Models\Type
 *
 * @property int $id
 * @property int|null $parent_id 上级id
 * @property string|null $name 影视分类名称
 * @property string|null $icon 分类图标
 * @property \Illuminate\Support\Carbon|null $created_at 创建时间
 * @property \Illuminate\Support\Carbon|null $updated_at 修改时间
 * @property int|null $sort
 * @property int|null $isdelete -1冻结0删除1正常
 * @method static \Illuminate\Database\Eloquent\Builder|Type newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|Type newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|Type query()
 * @method static \Illuminate\Database\Eloquent\Builder|Type whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Type whereIcon($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Type whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Type whereIsdelete($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Type whereName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Type whereParentId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Type whereSort($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Type whereUpdatedAt($value)
 * @mixin \Eloquent
 */
class Type extends Model
{
    //
    protected $table = 'type';
   public static function lists($parent = 1)
   {
       return self::where(['isdelete'=>1,'parent_id'=>$parent])->select('id','name','icon')->orderBy('sort','asc')->get();
   }
   public function getIconAttribute($value)
   {
       return env('APP_URL').'storage/uploads/'.$value;
   }
}
